package eightDataType.mStr;

import utils.PrintUtil;

/**
 * @author Ajie
 * @date 2022/9/2
 * @function
 * s.split(" ");//hello "" world 存在 ""
 *
 * //s.trim() 除去开头和末尾的空白字符  !!!重点。去掉后 s.split(\\s+) 就不会有 "" 了。
 * str2.split("\\s+");//,hello,world,  也存在 ""
 *
 *
 */
public class StingSplitDemo {
    public static void main(String[] args) {
        String s = "hello  world";
        //有空格
        String[] s1 = s.split(" ");//hello "" world
        PrintUtil.print(s1);

        System.err.println("StingSplitDemo:main:");
        String[] split = s.split("\\s+");//hello world
        PrintUtil.print(split);

        System.err.println("StingSplitDemo:main:>>>>");

        String str2 = " hello world";
        //有空格
        String[] s12 = str2.split(" ");//hello "" world
        PrintUtil.print(s12);

        System.err.println("StingSplitDemo:main:");
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String[] split2 = str2.split("\\s+");//,hello,world,  也存在 ""
        PrintUtil.print(split2);
    }
}
